//import java.util.HashMap;
//import java.util.Arrays;
//import java.util.Map;
class Solution {
    public ListNode dfs(ListNode head){
        if(head==null||head.next==null)
            return head;
        ListNode cur=dfs(head.next);
        head.next.next=head;
        head.next=null;
        return cur;
    }
    public ListNode reverseList(ListNode head) {
        return dfs(head);
    }
}